<%@ page language="java" import="java.util.*,web.java.entity.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>EL语法</title>

  </head>
  
  <body>
    <%
    	//${域对象中保存的值 }
    	String name="cainter";
    	pageContext.setAttribute("name",name);
    	String requestName="monster";
    	pageContext.setAttribute("name",requestName,pageContext.REQUEST_SCOPE);
    	String sessionName="master";
    	pageContext.setAttribute("name",sessionName,pageContext.SESSION_SCOPE);
    	String applicationName="cyder";
    	pageContext.setAttribute("name",applicationName,pageContext.APPLICATION_SCOPE);
    	//${域对象中保存的对象}
    	Student s1=new Student("cainter","20");
    	Student s2=new Student("monster","18");
    	Student s3=new Student("master","30");
    	Student s4=new Student("cyder","26");
    	pageContext.setAttribute("cainter",s1);
    	pageContext.setAttribute("monster",s2,pageContext.REQUEST_SCOPE);
    	pageContext.setAttribute("master",sessionName,pageContext.SESSION_SCOPE);
    	pageContext.setAttribute("cyder",applicationName,pageContext.APPLICATION_SCOPE);
    	//从集合对象中取，list，map
    	ArrayList<Student> studentList=new ArrayList<Student>();
    	studentList.add(s1);
    	studentList.add(s2);
    	studentList.add(s3);
    	studentList.add(s4);
    	pageContext.setAttribute("studentList",studentList);
    	Map<String,String> map=new HashMap<String, String>();
    	map.put("001", "cainter");
    	map.put("002","moster");
    	pageContext.setAttribute("map",map);
    	Map<String, Student> studentMap=new HashMap<String, Student>();
    	studentMap.put("cainter",s1);
    	studentMap.put("monster",s2);
    	pageContext.setAttribute("studentMap",studentMap);
    %>
    <p>默认是findAttribute()方法，page->request->session->application</p>
    <p>从page域中取：${name}</p>
    <p>从request中取：${requestScope.name }</p>
    <p>从session中取：${sessionScope.name }</p>
    <p>从application中取：${applicationScope.name }</p>
    <hr/>
    <p>取对象：${cainter }</p>
    <p>取对象中的属性值，本质是从get中取：${cainter.name }-${cainter.age }</p>
    <hr/>
    <p>取List对象：${studentList }</p>
    <p>取List中单个对象：${studentList[1] }</p>
    <p>取List中对个对象的属性：${studentList[1].name }-${studentList[1].age }</p>
    <hr/>
    <p>取map对象：${map }</p>
    <p>取map中单个属性：${map['001'] }</p>
    <p>取studentMap中单个对象：${studentMap['cainter'] }</p>
    <p>取studentMap中单个对象的属性：${studentMap['monster'].name }-${studentMap['monster'].age }</p>
    
    
  </body>
</html>
